from pyramid.config import Configurator
from pyramid.session import UnencryptedCookieSessionFactoryConfig


def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')

    config = Configurator(settings=settings, session_factory=my_session_factory)
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.include('pyramid_chameleon')

    config.add_route('IndexRoute', '/Index')
    config.add_route('DiscoveryRoute', '/discovery')
    config.add_route('StartRoute', '/start')
    config.add_route('SignupRoute', '/signup')
    config.add_route('LoginRoute', '/login')
    config.add_route('SearchRoute', '/search')
    config.add_route('ForgetRoute', '/forget')

    config.add_route('AppLoginRoute', '/AppLogin')
    config.add_route('AppLoginVerifyRoute', '/AppLoginVerify')
    config.add_route('AppQLoginVerifyRoute', '/AppQLoginVerify')
    config.add_route('AppIndexRoute', '/AppIndex')
    config.add_route('AppRegisterRoute', '/AppRegister')
    config.add_route('AppImageFetchRoute', '/AppImageFetch')
    #config.add_route('AppUploadRoute', '/AppUpload')
    config.add_route('AppChecksumRoute', '/AppChecksum')
    config.add_route('AppInforEditRoute', '/AppInforEdit')
    config.add_route('AppPortraitEditRoute', '/AppPortraitEdit')
    config.add_route('AppCollectionUploadRoute', '/AppCollectionUpload')
    config.add_route('AppCreationUploadRoute', '/AppCreationUpload')
    config.add_route('AppAchievementUploadRoute', '/AppAchievementUpload')
    config.add_route('AppAchievementFetchRoute', '/AppAchievementFetch')
    config.add_route('AppCollectionRemoveRoute', '/AppCollectionRemove')
    config.add_route('AppPwdForgetRoute', '/AppPwdForget')
    config.add_route('AppCommunityUrlFetchRoute', '/AppCommunityUrlFetch')
    config.add_route('AppCreationRemoveRoute', '/AppCreationRemove')

    config.add_route('AppWebLoginRoute', '/')
    config.add_route('AppWebLoginVerifyRoute', '/AppWebLoginVerify')
    config.add_route('AppWebIndexRoute', '/AppWebIndex')
    config.add_route('AppWebIndexSimpleRoute', '/AppWebIndexSimple')
    config.add_route('AppWebUploadRoute', '/AppWebUpload')
    config.add_route('AppWebUploadIndexRoute', '/AppWebUploadIndex')
    config.add_route('AppWebImageFetchRoute', '/AppWebImageFetch')
    config.add_route('AppWebItemEditIndexRoute', '/AppWebItemEditIndex')
    config.add_route('AppWebItemEditRoute', '/AppWebItemEdit')
    config.add_route('AppWebItemDeleteRoute', '/AppWebItemDelete')
    config.add_route('AppWebRedirectRoute', '/AppWebRedirect')
    config.add_route('AppWebPortraitEditRoute', 'AppWebPortraitEdit')
    config.add_route('AppWebLogoutRoute', 'AppWebLogout')

    config.scan()
    return config.make_wsgi_app()
